package com.zc.operator.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zc.operator.domain.ChargeOperatorUser;
import com.zc.operator.service.IChargeOperatorUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运营商用户Controller
 *
 * @author glb
 * @date 2023-05-16
 */
@RestController
@RequestMapping("/operator/user")
public class ChargeOperatorUserController extends BaseController
{
    @Autowired
    private IChargeOperatorUserService chargeOperatorUserService;

    /**
     * 查询运营商用户列表
     */
    @PreAuthorize("@ss.hasPermi('operator:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeOperatorUser chargeOperatorUser)
    {
        startPage();
        List<ChargeOperatorUser> list = chargeOperatorUserService.selectChargeOperatorUserList(chargeOperatorUser);
        return getDataTable(list);
    }

    /**
     * 导出运营商用户列表
     */
    @PreAuthorize("@ss.hasPermi('operator:user:export')")
    @Log(title = "运营商用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeOperatorUser chargeOperatorUser)
    {
        List<ChargeOperatorUser> list = chargeOperatorUserService.selectChargeOperatorUserList(chargeOperatorUser);
        ExcelUtil<ChargeOperatorUser> util = new ExcelUtil<>(ChargeOperatorUser.class);
        util.exportExcel(response, list, "运营商用户数据");
    }

    /**
     * 获取运营商用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('operator:user:query')")
    @GetMapping(value = "/{operatorId}")
    public AjaxResult getInfo(@PathVariable("operatorId") Long operatorId)
    {
        return AjaxResult.success(chargeOperatorUserService.selectChargeOperatorUserByOperatorId(operatorId));
    }

    /**
     * 新增运营商用户
     */
    @PreAuthorize("@ss.hasPermi('operator:user:add')")
    @Log(title = "运营商用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeOperatorUser chargeOperatorUser)
    {
        return toAjax(chargeOperatorUserService.insertChargeOperatorUser(chargeOperatorUser));
    }

    /**
     * 修改运营商用户
     */
    @PreAuthorize("@ss.hasPermi('operator:user:edit')")
    @Log(title = "运营商用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeOperatorUser chargeOperatorUser)
    {
        return toAjax(chargeOperatorUserService.updateChargeOperatorUser(chargeOperatorUser));
    }

    /**
     * 删除运营商用户
     */
    @PreAuthorize("@ss.hasPermi('operator:user:remove')")
    @Log(title = "运营商用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operatorIds}")
    public AjaxResult remove(@PathVariable Long[] operatorIds)
    {
        return toAjax(chargeOperatorUserService.deleteChargeOperatorUserByOperatorIds(operatorIds));
    }
}
